6
6
from uuid import uuid4
7
7
8
8
from git import Repo
9
- import bizarro
9
+ import bizarro , jekyll
10
10
11
11
#
12
12
# Tarball of a single-commit Git repo with files index.md and sub/index.md
@@ -35,10 +35,11 @@ def test_repo_features(self):
35
35
self .assertEqual (set (branch_names ), set (['master' , 'title' , 'body' ]))
36
36
37
37
def test_start_branch (self ):
38
- branch1 = bizarro .repo .start_branch (self .clone1 , 'master' , 'hello' )
38
+ name = str (uuid4 ())
39
+ branch1 = bizarro .repo .start_branch (self .clone1 , 'master' , name )
39
40
40
- self .assertTrue ('hello' in self .clone1 .branches )
41
- self .assertTrue ('hello' in self .origin .branches )
41
+ self .assertTrue (name in self .clone1 .branches )
42
+ self .assertTrue (name in self .origin .branches )
42
43
43
44
#
44
45
# Make a change to the branch and push it.
@@ -54,12 +55,49 @@ def test_start_branch(self):
54
55
#
55
56
# See if the branch made it to clone 2
56
57
#
57
- branch2 = bizarro .repo .start_branch (self .clone2 , 'master' , 'hello' )
58
+ branch2 = bizarro .repo .start_branch (self .clone2 , 'master' , name )
58
59
59
- self .assertTrue ('hello' in self .clone2 .branches )
60
+ self .assertTrue (name in self .clone2 .branches )
60
61
self .assertEquals (branch2 .commit .hexsha , branch1 .commit .hexsha )
61
62
self .assertEquals (branch2 .commit .message , message )
62
63
64
+ def test_new_file (self ):
65
+ name = str (uuid4 ())
66
+ branch1 = bizarro .repo .start_branch (self .clone1 , 'master' , name )
67
+
68
+ self .assertTrue (name in self .clone1 .branches )
69
+ self .assertTrue (name in self .origin .branches )
70
+
71
+ #
72
+ # Make a new file in the branch and push it.
73
+ #
74
+ branch1 .checkout ()
75
+ message = str (uuid4 ())
76
+
77
+ repo_path , real_path = bizarro .repo .make_working_file (self .clone1 , '' , 'hello.md' )
78
+
79
+ with open (real_path , 'w' ) as file :
80
+ jekyll .dump_jekyll_doc (dict (title = 'Hello' ), 'Hello hello.' , file )
81
+
82
+ bizarro .repo .save_working_file (self .clone1 , 'hello.md' , message , branch1 .commit .hexsha )
83
+
84
+ #
85
+ # See if the branch made it to clone 2
86
+ #
87
+ branch2 = bizarro .repo .start_branch (self .clone2 , 'master' , name )
88
+
89
+ self .assertTrue (name in self .clone2 .branches )
90
+ self .assertEquals (branch2 .commit .hexsha , branch1 .commit .hexsha )
91
+ self .assertEquals (branch2 .commit .message , message )
92
+
93
+ branch2 .checkout ()
94
+
95
+ with open (join (self .clone2 .working_dir , 'hello.md' )) as file :
96
+ front , body = jekyll .load_jekyll_doc (file )
97
+
98
+ self .assertEquals (front ['title' ], 'Hello' )
99
+ self .assertEquals (body , 'Hello hello.' )
100
+
63
101
def tearDown (self ):
64
102
rmtree (self .origin .git_dir )
65
103
rmtree (self .clone1 .working_dir )
0 commit comments