contentflow 1.1.0__tar.gz → 1.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: contentflow
3
- Version: 1.1.0
3
+ Version: 1.2.0
4
4
  Summary: Multi-platform AI marketing content generator with calendar, SEO optimizer, brand voices, and multi-language support
5
5
  Author-email: Teyfik OZ <teyfikoz@yahoo.com>
6
6
  License: MIT
@@ -22,12 +22,16 @@ Requires-Dist: requests>=2.31.0
22
22
  Provides-Extra: dev
23
23
  Requires-Dist: pytest>=7.0; extra == "dev"
24
24
  Requires-Dist: ruff>=0.1.0; extra == "dev"
25
+ Provides-Extra: mcp
26
+ Requires-Dist: mcp>=1.0; extra == "mcp"
27
+ Requires-Dist: pydantic>=2.0; extra == "mcp"
25
28
 
26
29
  # ContentFlow
27
30
 
28
31
  **Multi-platform AI marketing content generator** — Instagram, LinkedIn, Twitter, TikTok, Email, Blog, SEO. Works offline with curated templates or online with HuggingFace AI.
29
32
 
30
33
  [![PyPI version](https://badge.fury.io/py/contentflow.svg)](https://pypi.org/project/contentflow/)
34
+ [![Build](https://github.com/teyfikoz/contentflow/actions/workflows/publish.yml/badge.svg)](https://github.com/teyfikoz/contentflow/actions/workflows/publish.yml)
31
35
  [![CI](https://github.com/teyfikoz/contentflow/actions/workflows/ci.yml/badge.svg)](https://github.com/teyfikoz/contentflow/actions/workflows/ci.yml)
32
36
  [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/)
33
37
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
@@ -3,6 +3,7 @@
3
3
  **Multi-platform AI marketing content generator** — Instagram, LinkedIn, Twitter, TikTok, Email, Blog, SEO. Works offline with curated templates or online with HuggingFace AI.
4
4
 
5
5
  [![PyPI version](https://badge.fury.io/py/contentflow.svg)](https://pypi.org/project/contentflow/)
6
+ [![Build](https://github.com/teyfikoz/contentflow/actions/workflows/publish.yml/badge.svg)](https://github.com/teyfikoz/contentflow/actions/workflows/publish.yml)
6
7
  [![CI](https://github.com/teyfikoz/contentflow/actions/workflows/ci.yml/badge.svg)](https://github.com/teyfikoz/contentflow/actions/workflows/ci.yml)
7
8
  [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/)
8
9
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
@@ -1,8 +1,8 @@
1
1
  """
2
- ContentFlow v1.0.0 — Multi-platform AI marketing content generator.
2
+ ContentFlow v1.2.0 — Multi-platform AI marketing content generator with A/B testing.
3
3
  """
4
4
 
5
- __version__ = "1.1.0"
5
+ __version__ = "1.2.0"
6
6
 
7
7
  from .calendar import ContentCalendar, ContentWeek, ScheduledPost
8
8
  from .generator import ContentGenerator, ContentScore
@@ -393,6 +393,77 @@ class ContentGenerator:
393
393
  overall=round(overall, 2),
394
394
  )
395
395
 
396
+ # ── A/B Variant Generator ─────────────────────────────────────────────────
397
+
398
+ def generate_ab_variants(
399
+ self,
400
+ topic: str,
401
+ platform: str = "instagram",
402
+ hashtag_category: str = "tech",
403
+ ) -> dict[str, str]:
404
+ """
405
+ Generate two A/B test content variants for the same topic.
406
+
407
+ Variant A uses a curiosity/question hook; Variant B uses a bold
408
+ statement/authority hook. Both are platform-optimised and scored.
409
+
410
+ Args:
411
+ topic: Main subject (e.g. "AI automation", "summer sale")
412
+ platform: Target platform (instagram/linkedin/twitter/tiktok/...)
413
+ hashtag_category: Hashtag category for both variants
414
+
415
+ Returns:
416
+ Dict with keys ``"variant_a"``, ``"variant_b"``, ``"scores"``:
417
+ ``{"variant_a": "...", "variant_b": "...", "scores": {"a": ContentScore, "b": ContentScore}}``
418
+
419
+ Example::
420
+
421
+ cg = ContentGenerator(brand_voice="startup")
422
+ result = cg.generate_ab_variants("AI automation", platform="linkedin")
423
+ print(result["variant_a"])
424
+ print(result["variant_b"])
425
+ print("Best:", "A" if result["scores"]["a"].overall >= result["scores"]["b"].overall else "B")
426
+ """
427
+ tags = random.sample(HASHTAG_SETS.get(hashtag_category, HASHTAG_SETS["tech"]), 3)
428
+ emoji = "🚀" if self.brand_voice["emoji"] else ""
429
+
430
+ # Variant A — curiosity / question hook
431
+ hook_a = f"What if {topic} could change how you work forever?"
432
+ body_a = f"Most people don't realise how powerful {topic} really is. Here's the truth:"
433
+
434
+ # Variant B — bold statement / authority hook
435
+ hook_b = f"{topic} just got a whole lot more interesting."
436
+ body_b = f"After months of research, here are the top 3 things you need to know about {topic}:"
437
+
438
+ platform_lc = platform.lower()
439
+ templates = PLATFORM_TEMPLATES.get(platform_lc, PLATFORM_TEMPLATES["instagram"])
440
+
441
+ # Use first template for A, second (or first again) for B
442
+ tpl_a = templates[0]
443
+ tpl_b = templates[1] if len(templates) > 1 else templates[0]
444
+
445
+ common = dict(
446
+ topic=topic, emoji=emoji,
447
+ tag1=tags[0], tag2=tags[1], tag3=tags[2] if len(tags) > 2 else tags[0],
448
+ point1=f"{topic} drives real ROI",
449
+ point2="Most competitors are already using it",
450
+ point3="You can start in under 10 minutes",
451
+ insight=f"{topic} is the new competitive edge",
452
+ name="there", cta=f"Try {topic} today", url="bit.ly/learn",
453
+ )
454
+
455
+ variant_a = tpl_a.format(hook=hook_a, body=body_a, **common)
456
+ variant_b = tpl_b.format(hook=hook_b, body=body_b, **common)
457
+
458
+ score_a = self.score_content(variant_a, platform_lc)
459
+ score_b = self.score_content(variant_b, platform_lc)
460
+
461
+ return {
462
+ "variant_a": variant_a,
463
+ "variant_b": variant_b,
464
+ "scores": {"a": score_a, "b": score_b},
465
+ }
466
+
396
467
  # ── Travel quotes (backward compat) ──────────────────────────────────────
397
468
 
398
469
  def get_travel_quote(self, category: str = "Adventure") -> str:
@@ -0,0 +1,185 @@
1
+ """FastMCP server for ContentFlow — exposes content generation to LLM agents."""
2
+ from __future__ import annotations
3
+
4
+ from typing import Optional
5
+
6
+ from mcp.server.fastmcp import FastMCP
7
+
8
+ from . import ContentGenerator, ContentCalendar, SEOOptimizer, __version__
9
+ from .schemas import GeneratedContentSchema, MetaBundleSchema, ContentCalendarSchema, ABVariantSchema
10
+
11
+ mcp = FastMCP(
12
+ "ContentFlow",
13
+ instructions=(
14
+ f"ContentFlow v{__version__} — AI marketing content generator. "
15
+ "Tools: generate social media content, plan content calendars, "
16
+ "optimize SEO meta tags, create A/B variants."
17
+ ),
18
+ )
19
+
20
+ _gen = ContentGenerator()
21
+ _cal = ContentCalendar()
22
+ _seo = SEOOptimizer()
23
+
24
+
25
+ @mcp.tool()
26
+ def generate_content(
27
+ topic: str,
28
+ platform: str = "instagram",
29
+ tone: str = "engaging",
30
+ ) -> dict:
31
+ """
32
+ Generate marketing content for a topic and platform.
33
+
34
+ Args:
35
+ topic: Content topic or keyword
36
+ platform: 'instagram' | 'linkedin' | 'twitter' | 'facebook' | 'tiktok'
37
+ tone: 'engaging' | 'professional' | 'humorous' | 'inspirational'
38
+
39
+ Returns:
40
+ GeneratedContentSchema with content text and quality score
41
+ """
42
+ try:
43
+ content = _gen.generate(topic, platform=platform, tone=tone)
44
+ score = _gen.score_content(content, platform=platform)
45
+ return GeneratedContentSchema(
46
+ topic=topic,
47
+ platform=platform,
48
+ content=content,
49
+ tone=tone,
50
+ summary=f"{platform} post for '{topic}' (tone: {tone})",
51
+ ).model_dump()
52
+ except Exception as exc:
53
+ return {"error": str(exc)}
54
+
55
+
56
+ @mcp.tool()
57
+ def generate_ab_variants(
58
+ topic: str,
59
+ platform: str = "instagram",
60
+ n_variants: int = 3,
61
+ ) -> dict:
62
+ """
63
+ Generate A/B test variants for a content topic.
64
+
65
+ Args:
66
+ topic: Content topic
67
+ platform: Target platform
68
+ n_variants: Number of variants to generate (2–5)
69
+
70
+ Returns:
71
+ List of content variants for A/B testing
72
+ """
73
+ try:
74
+ variants = _gen.generate_ab_variants(topic, platform=platform, n_variants=n_variants)
75
+ result = []
76
+ for i, v in enumerate(variants):
77
+ if isinstance(v, str):
78
+ result.append(ABVariantSchema(
79
+ variant=f"V{i+1}", content=v, hook=v[:80],
80
+ ).model_dump())
81
+ else:
82
+ result.append(ABVariantSchema(
83
+ variant=f"V{i+1}",
84
+ content=str(getattr(v, "content", v)),
85
+ hook=str(getattr(v, "hook", str(v)[:80])),
86
+ ).model_dump())
87
+ return {"topic": topic, "platform": platform, "variants": result}
88
+ except Exception as exc:
89
+ return {"error": str(exc)}
90
+
91
+
92
+ @mcp.tool()
93
+ def plan_calendar(
94
+ topics: list[str],
95
+ platform: str = "instagram",
96
+ week: int = 1,
97
+ ) -> dict:
98
+ """
99
+ Plan a content calendar week for given topics.
100
+
101
+ Args:
102
+ topics: List of content topics for the week
103
+ platform: Target platform
104
+ week: Week number (1-52)
105
+
106
+ Returns:
107
+ ContentCalendarSchema with scheduled posts per day
108
+ """
109
+ try:
110
+ calendar_week = _cal.plan_week(topics, platform=platform, week=week)
111
+ posts = []
112
+ for post in getattr(calendar_week, "posts", []):
113
+ posts.append({
114
+ "date": str(getattr(post, "date", "")),
115
+ "platform": str(getattr(post, "platform", platform)),
116
+ "content": str(getattr(post, "content", "")),
117
+ "topic": str(getattr(post, "topic", "")),
118
+ "hashtags": list(getattr(post, "hashtags", [])),
119
+ })
120
+ return {
121
+ "week": week,
122
+ "platform": platform,
123
+ "posts": posts,
124
+ "total_posts": len(posts),
125
+ "summary": f"Week {week}: {len(posts)} posts planned on {platform}",
126
+ }
127
+ except Exception as exc:
128
+ return {"error": str(exc)}
129
+
130
+
131
+ @mcp.tool()
132
+ def optimize_seo(
133
+ title: str,
134
+ content: str,
135
+ target_keywords: Optional[list[str]] = None,
136
+ ) -> dict:
137
+ """
138
+ Optimize SEO meta tags for a page title and content.
139
+
140
+ Args:
141
+ title: Page or post title
142
+ content: Page content (first 1000 chars used for analysis)
143
+ target_keywords: Optional list of target keywords
144
+
145
+ Returns:
146
+ MetaBundleSchema with optimized title, description, og tags, keywords
147
+ """
148
+ try:
149
+ result = _seo.optimize(title, content[:1000], keywords=target_keywords or [])
150
+ return MetaBundleSchema.from_result(result).model_dump()
151
+ except Exception as exc:
152
+ return {"error": str(exc)}
153
+
154
+
155
+ @mcp.tool()
156
+ def score_content(content: str, platform: str = "instagram") -> dict:
157
+ """
158
+ Score existing content for engagement, readability, and SEO.
159
+
160
+ Args:
161
+ content: Content text to score
162
+ platform: Platform context for scoring
163
+
164
+ Returns:
165
+ Dict with overall, engagement, readability, and SEO scores (0-10)
166
+ """
167
+ try:
168
+ result = _gen.score_content(content, platform=platform)
169
+ return {
170
+ "overall": float(getattr(result, "overall", 0.0)),
171
+ "engagement": float(getattr(result, "engagement", 0.0)),
172
+ "readability": float(getattr(result, "readability", 0.0)),
173
+ "seo": float(getattr(result, "seo", 0.0)),
174
+ "summary": str(result),
175
+ }
176
+ except Exception as exc:
177
+ return {"error": str(exc)}
178
+
179
+
180
+ def main() -> None:
181
+ mcp.run(transport="stdio")
182
+
183
+
184
+ if __name__ == "__main__":
185
+ main()
@@ -0,0 +1,85 @@
1
+ """Pydantic v2 schemas for ContentFlow — MCP + FastAPI integration."""
2
+ from __future__ import annotations
3
+
4
+ from typing import Optional
5
+
6
+ from pydantic import BaseModel
7
+
8
+
9
+ class ContentScoreSchema(BaseModel):
10
+ overall: float
11
+ engagement: float
12
+ readability: float
13
+ seo: float
14
+ summary: str
15
+
16
+ @classmethod
17
+ def from_result(cls, r) -> "ContentScoreSchema":
18
+ return cls(
19
+ overall=float(getattr(r, "overall", 0.0)),
20
+ engagement=float(getattr(r, "engagement", 0.0)),
21
+ readability=float(getattr(r, "readability", 0.0)),
22
+ seo=float(getattr(r, "seo", 0.0)),
23
+ summary=f"Content score: {getattr(r, 'overall', 0.0):.1f}/10",
24
+ )
25
+
26
+
27
+ class GeneratedContentSchema(BaseModel):
28
+ topic: str
29
+ platform: str
30
+ content: str
31
+ tone: str
32
+ score: Optional[ContentScoreSchema] = None
33
+ summary: str
34
+
35
+
36
+ class MetaBundleSchema(BaseModel):
37
+ title: str
38
+ description: str
39
+ keywords: list[str]
40
+ og_title: str
41
+ og_description: str
42
+ summary: str
43
+
44
+ @classmethod
45
+ def from_result(cls, r) -> "MetaBundleSchema":
46
+ return cls(
47
+ title=r.title,
48
+ description=r.description,
49
+ keywords=list(r.keywords) if hasattr(r, "keywords") else [],
50
+ og_title=getattr(r, "og_title", r.title),
51
+ og_description=getattr(r, "og_description", r.description),
52
+ summary=f"SEO meta: '{r.title[:50]}' | {len(getattr(r, 'keywords', []))} keywords",
53
+ )
54
+
55
+
56
+ class ScheduledPostSchema(BaseModel):
57
+ date: str
58
+ platform: str
59
+ content: str
60
+ topic: str
61
+ hashtags: list[str]
62
+
63
+
64
+ class ContentCalendarSchema(BaseModel):
65
+ week: int
66
+ platform: str
67
+ posts: list[ScheduledPostSchema]
68
+ total_posts: int
69
+ summary: str
70
+
71
+
72
+ class ABVariantSchema(BaseModel):
73
+ variant: str
74
+ content: str
75
+ hook: str
76
+
77
+
78
+ __all__ = [
79
+ "ContentScoreSchema",
80
+ "GeneratedContentSchema",
81
+ "MetaBundleSchema",
82
+ "ScheduledPostSchema",
83
+ "ContentCalendarSchema",
84
+ "ABVariantSchema",
85
+ ]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: contentflow
3
- Version: 1.1.0
3
+ Version: 1.2.0
4
4
  Summary: Multi-platform AI marketing content generator with calendar, SEO optimizer, brand voices, and multi-language support
5
5
  Author-email: Teyfik OZ <teyfikoz@yahoo.com>
6
6
  License: MIT
@@ -22,12 +22,16 @@ Requires-Dist: requests>=2.31.0
22
22
  Provides-Extra: dev
23
23
  Requires-Dist: pytest>=7.0; extra == "dev"
24
24
  Requires-Dist: ruff>=0.1.0; extra == "dev"
25
+ Provides-Extra: mcp
26
+ Requires-Dist: mcp>=1.0; extra == "mcp"
27
+ Requires-Dist: pydantic>=2.0; extra == "mcp"
25
28
 
26
29
  # ContentFlow
27
30
 
28
31
  **Multi-platform AI marketing content generator** — Instagram, LinkedIn, Twitter, TikTok, Email, Blog, SEO. Works offline with curated templates or online with HuggingFace AI.
29
32
 
30
33
  [![PyPI version](https://badge.fury.io/py/contentflow.svg)](https://pypi.org/project/contentflow/)
34
+ [![Build](https://github.com/teyfikoz/contentflow/actions/workflows/publish.yml/badge.svg)](https://github.com/teyfikoz/contentflow/actions/workflows/publish.yml)
31
35
  [![CI](https://github.com/teyfikoz/contentflow/actions/workflows/ci.yml/badge.svg)](https://github.com/teyfikoz/contentflow/actions/workflows/ci.yml)
32
36
  [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/)
33
37
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
@@ -3,10 +3,13 @@ pyproject.toml
3
3
  contentflow/__init__.py
4
4
  contentflow/calendar.py
5
5
  contentflow/generator.py
6
+ contentflow/mcp_server.py
7
+ contentflow/schemas.py
6
8
  contentflow/seo.py
7
9
  contentflow.egg-info/PKG-INFO
8
10
  contentflow.egg-info/SOURCES.txt
9
11
  contentflow.egg-info/dependency_links.txt
12
+ contentflow.egg-info/entry_points.txt
10
13
  contentflow.egg-info/requires.txt
11
14
  contentflow.egg-info/top_level.txt
12
15
  tests/test_basic.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ contentflow-mcp = contentflow.mcp_server:main
@@ -3,3 +3,7 @@ requests>=2.31.0
3
3
  [dev]
4
4
  pytest>=7.0
5
5
  ruff>=0.1.0
6
+
7
+ [mcp]
8
+ mcp>=1.0
9
+ pydantic>=2.0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "contentflow"
7
- version = "1.1.0"
7
+ version = "1.2.0"
8
8
  description = "Multi-platform AI marketing content generator with calendar, SEO optimizer, brand voices, and multi-language support"
9
9
  readme = "README.md"
10
10
  authors = [
@@ -32,6 +32,13 @@ dev = [
32
32
  "pytest>=7.0",
33
33
  "ruff>=0.1.0",
34
34
  ]
35
+ mcp = [
36
+ "mcp>=1.0",
37
+ "pydantic>=2.0",
38
+ ]
39
+
40
+ [project.scripts]
41
+ contentflow-mcp = "contentflow.mcp_server:main"
35
42
 
36
43
  [project.urls]
37
44
  Homepage = "https://github.com/teyfikoz/contentflow"
@@ -0,0 +1,270 @@
1
+ """Tests for ContentFlow v1.2.0."""
2
+
3
+ import pytest
4
+
5
+
6
+ def test_version():
7
+ import contentflow
8
+ assert contentflow.__version__ == "1.2.0"
9
+
10
+
11
+ def test_all_exports():
12
+ from contentflow import ContentGenerator, ContentCalendar, SEOOptimizer
13
+ from contentflow import ContentScore, ContentWeek, ScheduledPost, MetaBundle
14
+ assert all(cls is not None for cls in [ContentGenerator, ContentCalendar, SEOOptimizer])
15
+
16
+
17
+ # ── ContentGenerator ──────────────────────────────────────────────────────────
18
+
19
+ def test_generate_ad_copy_backward_compat():
20
+ from contentflow import ContentGenerator
21
+ gen = ContentGenerator()
22
+ copy = gen.generate_ad_copy("Istanbul", vibe="exciting", platform="Instagram")
23
+ assert isinstance(copy, str)
24
+ assert "Istanbul" in copy
25
+
26
+
27
+ def test_generate_multi_platform():
28
+ from contentflow import ContentGenerator
29
+ gen = ContentGenerator()
30
+ for platform in ["instagram", "linkedin", "twitter", "tiktok", "email", "blog"]:
31
+ content = gen.generate("AI tools", platform=platform, tone="engaging")
32
+ assert isinstance(content, str)
33
+ assert len(content) > 10
34
+
35
+
36
+ def test_generate_brand_voices():
37
+ from contentflow import ContentGenerator
38
+ for voice in ["startup", "enterprise", "creative", "minimal", "friendly"]:
39
+ gen = ContentGenerator(brand_voice=voice)
40
+ content = gen.generate("product launch", platform="instagram")
41
+ assert isinstance(content, str)
42
+
43
+
44
+ def test_batch_generate():
45
+ from contentflow import ContentGenerator
46
+ gen = ContentGenerator()
47
+ results = gen.batch_generate(["Paris", "Tokyo", "Istanbul"], platform="instagram")
48
+ assert len(results) == 3
49
+ for r in results:
50
+ assert "topic" in r
51
+ assert "content" in r
52
+ assert isinstance(r["content"], str)
53
+
54
+
55
+ def test_score_content():
56
+ from contentflow import ContentGenerator
57
+ gen = ContentGenerator()
58
+ content = gen.generate("AI productivity", platform="linkedin")
59
+ score = gen.score_content(content, platform="linkedin")
60
+ assert 0.0 <= score.readability <= 1.0
61
+ assert 0.0 <= score.engagement <= 1.0
62
+ assert 0.0 <= score.overall <= 1.0
63
+
64
+
65
+ def test_get_travel_quote_all_categories():
66
+ from contentflow import ContentGenerator
67
+ gen = ContentGenerator()
68
+ for cat in ["Adventure", "Luxury", "Family", "Culture", "Mindset"]:
69
+ q = gen.get_travel_quote(cat)
70
+ assert isinstance(q, str)
71
+ assert len(q) > 10
72
+
73
+ # Unknown category → fallback
74
+ q = gen.get_travel_quote("Unknown")
75
+ assert isinstance(q, str)
76
+
77
+
78
+ def test_multilanguage():
79
+ from contentflow import ContentGenerator
80
+ for lang in ["en", "tr", "de", "fr", "es"]:
81
+ gen = ContentGenerator(language=lang)
82
+ content = gen.generate("digital marketing", platform="instagram")
83
+ assert isinstance(content, str)
84
+ assert len(content) > 5
85
+
86
+
87
+ # ── ContentCalendar ────────────────────────────────────────────────────────────
88
+
89
+ def test_content_calendar_generate_week():
90
+ from contentflow import ContentCalendar
91
+ cal = ContentCalendar()
92
+ week = cal.generate_week("machine learning", platforms=["linkedin", "twitter"])
93
+ assert len(week.posts) > 0
94
+ for post in week.posts:
95
+ assert post.platform in ("linkedin", "twitter")
96
+ assert isinstance(post.content, str)
97
+ assert len(post.content) > 5
98
+
99
+
100
+ def test_content_calendar_to_dict():
101
+ from contentflow import ContentCalendar
102
+ cal = ContentCalendar()
103
+ week = cal.generate_week("startup", platforms=["instagram"])
104
+ data = week.to_dict()
105
+ assert isinstance(data, list)
106
+ assert len(data) > 0
107
+ assert "content" in data[0]
108
+
109
+
110
+ def test_content_calendar_generate_month():
111
+ from contentflow import ContentCalendar
112
+ cal = ContentCalendar()
113
+ weeks = cal.generate_month(["AI", "marketing"], platforms=["twitter"])
114
+ assert len(weeks) == 4
115
+
116
+
117
+ # ── SEOOptimizer ──────────────────────────────────────────────────────────────
118
+
119
+ def test_seo_generate_meta():
120
+ from contentflow import SEOOptimizer
121
+ seo = SEOOptimizer()
122
+ bundle = seo.generate_meta("Istanbul travel guide 2026")
123
+ assert isinstance(bundle.title, str)
124
+ assert len(bundle.title) <= 60
125
+ assert len(bundle.description) <= 160
126
+ assert isinstance(bundle.keywords, list)
127
+ assert len(bundle.slug) > 0
128
+
129
+
130
+ def test_seo_generate_blog_outline():
131
+ from contentflow import SEOOptimizer
132
+ seo = SEOOptimizer()
133
+ outline = seo.generate_blog_outline("Top AI tools for small business", sections=5)
134
+ assert len(outline) == 5
135
+ for section in outline:
136
+ assert isinstance(section, str)
137
+ assert len(section) > 5
138
+
139
+
140
+ def test_seo_generate_title_styles():
141
+ from contentflow import SEOOptimizer
142
+ seo = SEOOptimizer()
143
+ for style in ["guide", "how-to", "list", "question", "comparison"]:
144
+ title = seo.generate_title("Python testing", style=style)
145
+ assert isinstance(title, str)
146
+ assert "Python" in title
147
+
148
+
149
+ # ── ContentScore __str__ ──────────��────────────────────────────────────────────
150
+
151
+ def test_content_score_str():
152
+ from contentflow import ContentGenerator
153
+ gen = ContentGenerator()
154
+ content = gen.generate("AI tools", platform="instagram")
155
+ score = gen.score_content(content, platform="instagram")
156
+ s = str(score)
157
+ assert "ContentScore" in s
158
+ assert "readability" in s
159
+
160
+
161
+ # ── generate() extra platforms ───���──────────────────────────────��──────────────
162
+
163
+ def test_generate_sms_push():
164
+ from contentflow import ContentGenerator
165
+ gen = ContentGenerator()
166
+ for platform in ["sms", "push"]:
167
+ content = gen.generate("flash sale", platform=platform)
168
+ assert isinstance(content, str)
169
+ assert len(content) > 5
170
+
171
+
172
+ # ── score_content edge cases ───────────────────────────────────��──────────────
173
+
174
+ def test_score_content_all_platforms():
175
+ from contentflow import ContentGenerator
176
+ gen = ContentGenerator()
177
+ for platform in ["instagram", "linkedin", "twitter", "tiktok", "email", "blog"]:
178
+ content = gen.generate("news", platform=platform)
179
+ score = gen.score_content(content, platform=platform)
180
+ assert 0.0 <= score.overall <= 1.0
181
+
182
+
183
+ def test_score_content_short_long():
184
+ from contentflow import ContentGenerator
185
+ gen = ContentGenerator()
186
+ score_short = gen.score_content("Hi!", platform="twitter")
187
+ score_long = gen.score_content("x " * 500, platform="twitter")
188
+ assert 0.0 <= score_short.length_fit <= 1.0
189
+ assert 0.0 <= score_long.length_fit <= 1.0
190
+
191
+
192
+ # ── ContentCalendar __str__ ────────────────────��──────────────────────────────
193
+
194
+ def test_scheduled_post_str():
195
+ from contentflow import ContentCalendar
196
+ cal = ContentCalendar()
197
+ week = cal.generate_week("cooking", platforms=["instagram"])
198
+ post = week.posts[0]
199
+ s = str(post)
200
+ assert "instagram" in s.lower() or "INSTAGRAM" in s
201
+
202
+
203
+ # ── SEO meta unknown style ──────────────────────────────────────���─────────────
204
+
205
+ def test_seo_generate_title_unknown_style():
206
+ from contentflow import SEOOptimizer
207
+ seo = SEOOptimizer()
208
+ title = seo.generate_title("python", style="unknown")
209
+ assert isinstance(title, str)
210
+
211
+
212
+ # ── ContentWeek __repr__ ───────────────────────────────────────────────────────
213
+
214
+ def test_content_week_repr():
215
+ from contentflow import ContentCalendar
216
+ cal = ContentCalendar()
217
+ week = cal.generate_week("travel", platforms=["instagram"])
218
+ r = repr(week)
219
+ assert "ContentWeek" in r
220
+
221
+
222
+ # ── ContentGenerator language templates (non-en) ──────────────────────────────
223
+
224
+ def test_generate_language_template_tr():
225
+ """Hit the language-template branch in _template_generate."""
226
+ from contentflow import ContentGenerator
227
+ gen = ContentGenerator(language="tr")
228
+ content = gen.generate("dijital pazarlama", platform="instagram")
229
+ assert isinstance(content, str)
230
+ assert len(content) > 5
231
+
232
+
233
+ # ── _ai_generate fallback (bad API key) ───────────────────────────────────────
234
+
235
+ def test_ai_generate_fallback_on_bad_key():
236
+ """_ai_generate falls back to template when API errors."""
237
+ from contentflow import ContentGenerator
238
+ gen = ContentGenerator(api_key="bad_test_key_xxx")
239
+ content = gen.generate("AI tools", platform="linkedin", tone="professional")
240
+ assert isinstance(content, str)
241
+ assert len(content) > 5
242
+
243
+
244
+ # ── A/B Variant Generator ─────────────────────────────────────────────────────
245
+
246
+ def test_generate_ab_variants_returns_two_variants():
247
+ from contentflow import ContentGenerator
248
+ cg = ContentGenerator(brand_voice="startup")
249
+ result = cg.generate_ab_variants("AI automation", platform="instagram", hashtag_category="tech")
250
+ assert "variant_a" in result
251
+ assert "variant_b" in result
252
+ assert "scores" in result
253
+ assert len(result["variant_a"]) > 10
254
+ assert len(result["variant_b"]) > 10
255
+
256
+
257
+ def test_generate_ab_variants_scores():
258
+ from contentflow import ContentGenerator
259
+ cg = ContentGenerator(brand_voice="friendly")
260
+ result = cg.generate_ab_variants("startup growth", platform="linkedin")
261
+ scores = result["scores"]
262
+ assert 0.0 <= scores["a"].overall <= 1.0
263
+ assert 0.0 <= scores["b"].overall <= 1.0
264
+
265
+
266
+ def test_generate_ab_variants_differ():
267
+ from contentflow import ContentGenerator
268
+ cg = ContentGenerator(brand_voice="minimal")
269
+ result = cg.generate_ab_variants("machine learning", platform="twitter")
270
+ assert result["variant_a"] != result["variant_b"]
@@ -1,146 +0,0 @@
1
- """Tests for ContentFlow v1.0.0."""
2
-
3
- import pytest
4
-
5
-
6
- def test_version():
7
- import contentflow
8
- assert contentflow.__version__ == "1.0.0"
9
-
10
-
11
- def test_all_exports():
12
- from contentflow import ContentGenerator, ContentCalendar, SEOOptimizer
13
- from contentflow import ContentScore, ContentWeek, ScheduledPost, MetaBundle
14
- assert all(cls is not None for cls in [ContentGenerator, ContentCalendar, SEOOptimizer])
15
-
16
-
17
- # ── ContentGenerator ──────────────────────────────────────────────────────────
18
-
19
- def test_generate_ad_copy_backward_compat():
20
- from contentflow import ContentGenerator
21
- gen = ContentGenerator()
22
- copy = gen.generate_ad_copy("Istanbul", vibe="exciting", platform="Instagram")
23
- assert isinstance(copy, str)
24
- assert "Istanbul" in copy
25
-
26
-
27
- def test_generate_multi_platform():
28
- from contentflow import ContentGenerator
29
- gen = ContentGenerator()
30
- for platform in ["instagram", "linkedin", "twitter", "tiktok", "email", "blog"]:
31
- content = gen.generate("AI tools", platform=platform, tone="engaging")
32
- assert isinstance(content, str)
33
- assert len(content) > 10
34
-
35
-
36
- def test_generate_brand_voices():
37
- from contentflow import ContentGenerator
38
- for voice in ["startup", "enterprise", "creative", "minimal", "friendly"]:
39
- gen = ContentGenerator(brand_voice=voice)
40
- content = gen.generate("product launch", platform="instagram")
41
- assert isinstance(content, str)
42
-
43
-
44
- def test_batch_generate():
45
- from contentflow import ContentGenerator
46
- gen = ContentGenerator()
47
- results = gen.batch_generate(["Paris", "Tokyo", "Istanbul"], platform="instagram")
48
- assert len(results) == 3
49
- for r in results:
50
- assert "topic" in r
51
- assert "content" in r
52
- assert isinstance(r["content"], str)
53
-
54
-
55
- def test_score_content():
56
- from contentflow import ContentGenerator
57
- gen = ContentGenerator()
58
- content = gen.generate("AI productivity", platform="linkedin")
59
- score = gen.score_content(content, platform="linkedin")
60
- assert 0.0 <= score.readability <= 1.0
61
- assert 0.0 <= score.engagement <= 1.0
62
- assert 0.0 <= score.overall <= 1.0
63
-
64
-
65
- def test_get_travel_quote_all_categories():
66
- from contentflow import ContentGenerator
67
- gen = ContentGenerator()
68
- for cat in ["Adventure", "Luxury", "Family", "Culture", "Mindset"]:
69
- q = gen.get_travel_quote(cat)
70
- assert isinstance(q, str)
71
- assert len(q) > 10
72
-
73
- # Unknown category → fallback
74
- q = gen.get_travel_quote("Unknown")
75
- assert isinstance(q, str)
76
-
77
-
78
- def test_multilanguage():
79
- from contentflow import ContentGenerator
80
- for lang in ["en", "tr", "de", "fr", "es"]:
81
- gen = ContentGenerator(language=lang)
82
- content = gen.generate("digital marketing", platform="instagram")
83
- assert isinstance(content, str)
84
- assert len(content) > 5
85
-
86
-
87
- # ── ContentCalendar ────────────────────────────────────────────────────────────
88
-
89
- def test_content_calendar_generate_week():
90
- from contentflow import ContentCalendar
91
- cal = ContentCalendar()
92
- week = cal.generate_week("machine learning", platforms=["linkedin", "twitter"])
93
- assert len(week.posts) > 0
94
- for post in week.posts:
95
- assert post.platform in ("linkedin", "twitter")
96
- assert isinstance(post.content, str)
97
- assert len(post.content) > 5
98
-
99
-
100
- def test_content_calendar_to_dict():
101
- from contentflow import ContentCalendar
102
- cal = ContentCalendar()
103
- week = cal.generate_week("startup", platforms=["instagram"])
104
- data = week.to_dict()
105
- assert isinstance(data, list)
106
- assert len(data) > 0
107
- assert "content" in data[0]
108
-
109
-
110
- def test_content_calendar_generate_month():
111
- from contentflow import ContentCalendar
112
- cal = ContentCalendar()
113
- weeks = cal.generate_month(["AI", "marketing"], platforms=["twitter"])
114
- assert len(weeks) == 4
115
-
116
-
117
- # ── SEOOptimizer ──────────────────────────────────────────────────────────────
118
-
119
- def test_seo_generate_meta():
120
- from contentflow import SEOOptimizer
121
- seo = SEOOptimizer()
122
- bundle = seo.generate_meta("Istanbul travel guide 2026")
123
- assert isinstance(bundle.title, str)
124
- assert len(bundle.title) <= 60
125
- assert len(bundle.description) <= 160
126
- assert isinstance(bundle.keywords, list)
127
- assert len(bundle.slug) > 0
128
-
129
-
130
- def test_seo_generate_blog_outline():
131
- from contentflow import SEOOptimizer
132
- seo = SEOOptimizer()
133
- outline = seo.generate_blog_outline("Top AI tools for small business", sections=5)
134
- assert len(outline) == 5
135
- for section in outline:
136
- assert isinstance(section, str)
137
- assert len(section) > 5
138
-
139
-
140
- def test_seo_generate_title_styles():
141
- from contentflow import SEOOptimizer
142
- seo = SEOOptimizer()
143
- for style in ["guide", "how-to", "list", "question", "comparison"]:
144
- title = seo.generate_title("Python testing", style=style)
145
- assert isinstance(title, str)
146
- assert "Python" in title
File without changes