MCPcopy
hub / github.com/liangliangyy/DjangoBlog / test_validate_article

Method test_validate_article

blog/tests.py:27–149  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

25 self.factory = RequestFactory()
26
27 def test_validate_article(self):
28 site = get_current_site().domain
29 user = BlogUser.objects.get_or_create(
30 email="liangliangyy@gmail.com",
31 username="liangliangyy")[0]
32 user.set_password("liangliangyy")
33 user.is_staff = True
34 user.is_superuser = True
35 user.save()
36 response = self.client.get(user.get_absolute_url())
37 self.assertEqual(response.status_code, 200)
38 response = self.client.get('/admin/servermanager/emailsendlog/')
39 response = self.client.get('admin/admin/logentry/')
40 s = SideBar()
41 s.sequence = 1
42 s.name = 'test'
43 s.content = 'test content'
44 s.is_enable = True
45 s.save()
46
47 category = Category()
48 category.name = "category"
49 category.creation_time = timezone.now()
50 category.last_mod_time = timezone.now()
51 category.save()
52
53 tag = Tag()
54 tag.name = "nicetag"
55 tag.save()
56
57 article = Article()
58 article.title = "nicetitle"
59 article.body = "nicecontent"
60 article.author = user
61 article.category = category
62 article.type = 'a'
63 article.status = 'p'
64
65 article.save()
66 self.assertEqual(0, article.tags.count())
67 article.tags.add(tag)
68 article.save()
69 self.assertEqual(1, article.tags.count())
70
71 for i in range(20):
72 article = Article()
73 article.title = "nicetitle" + str(i)
74 article.body = "nicetitle" + str(i)
75 article.author = user
76 article.category = category
77 article.type = 'a'
78 article.status = 'p'
79 article.save()
80 article.tags.add(tag)
81 article.save()
82 from blog.documents import ELASTICSEARCH_ENABLED
83 if ELASTICSEARCH_ENABLED:
84 call_command("build_index")

Callers

nothing calls this directly

Calls 15

saveMethod · 0.95
get_absolute_urlMethod · 0.95
get_absolute_urlMethod · 0.95
get_absolute_urlMethod · 0.95
check_paginationMethod · 0.95
searchMethod · 0.95
get_current_siteFunction · 0.90
SideBarClass · 0.90
CategoryClass · 0.90
TagClass · 0.90
ArticleClass · 0.90
load_articletagsFunction · 0.90

Tested by

no test coverage detected