@@ -42,14 +42,14 @@ def test_add_no_constraint(app, repo, installer):
42
42
assert content ["dependencies" ]["cachy" ] == "^0.2.0"
43
43
44
44
45
- def test_add_constraint (app , repo , installer ):
45
+ def test_add_equal_constraint (app , repo , installer ):
46
46
command = app .find ("add" )
47
47
tester = CommandTester (command )
48
48
49
49
repo .add_package (get_package ("cachy" , "0.1.0" ))
50
50
repo .add_package (get_package ("cachy" , "0.2.0" ))
51
51
52
- tester .execute ("cachy=0.1.0" )
52
+ tester .execute ("cachy== 0.1.0" )
53
53
54
54
expected = """\
55
55
@@ -69,6 +69,67 @@ def test_add_constraint(app, repo, installer):
69
69
assert len (installer .installs ) == 1
70
70
71
71
72
+ def test_add_greater_constraint (app , repo , installer ):
73
+ command = app .find ("add" )
74
+ tester = CommandTester (command )
75
+
76
+ repo .add_package (get_package ("cachy" , "0.1.0" ))
77
+ repo .add_package (get_package ("cachy" , "0.2.0" ))
78
+
79
+ tester .execute ("cachy>=0.1.0" )
80
+
81
+ expected = """\
82
+
83
+ Updating dependencies
84
+ Resolving dependencies...
85
+
86
+ Writing lock file
87
+
88
+
89
+ Package operations: 1 install, 0 updates, 0 removals
90
+
91
+ - Installing cachy (0.2.0)
92
+ """
93
+
94
+ assert expected == tester .io .fetch_output ()
95
+
96
+ assert len (installer .installs ) == 1
97
+
98
+
99
+ def test_add_constraint_with_extras (app , repo , installer ):
100
+ command = app .find ("add" )
101
+ tester = CommandTester (command )
102
+
103
+ cachy1 = get_package ("cachy" , "0.1.0" )
104
+ cachy1 .extras = {"msgpack" : [get_dependency ("msgpack-python" )]}
105
+ msgpack_dep = get_dependency ("msgpack-python" , ">=0.5 <0.6" , optional = True )
106
+ cachy1 .requires = [msgpack_dep ]
107
+
108
+ repo .add_package (get_package ("cachy" , "0.2.0" ))
109
+ repo .add_package (cachy1 )
110
+ repo .add_package (get_package ("msgpack-python" , "0.5.3" ))
111
+
112
+ tester .execute ("cachy[msgpack]^0.1.0" )
113
+
114
+ expected = """\
115
+
116
+ Updating dependencies
117
+ Resolving dependencies...
118
+
119
+ Writing lock file
120
+
121
+
122
+ Package operations: 2 installs, 0 updates, 0 removals
123
+
124
+ - Installing msgpack-python (0.5.3)
125
+ - Installing cachy (0.1.0)
126
+ """
127
+
128
+ assert expected == tester .io .fetch_output ()
129
+
130
+ assert len (installer .installs ) == 2
131
+
132
+
72
133
def test_add_constraint_dependencies (app , repo , installer ):
73
134
command = app .find ("add" )
74
135
tester = CommandTester (command )
@@ -164,6 +225,45 @@ def test_add_git_constraint_with_poetry(app, repo, installer):
164
225
assert len (installer .installs ) == 2
165
226
166
227
228
+ def test_add_git_constraint_with_extras (app , repo , installer ):
229
+ command = app .find ("add" )
230
+ tester = CommandTester (command )
231
+
232
+ repo .add_package (get_package ("pendulum" , "1.4.4" ))
233
+ repo .add_package (get_package ("cleo" , "0.6.5" ))
234
+ repo .add_package (get_package ("tomlkit" , "0.5.5" ))
235
+
236
+ tester .execute ("git+https://github.com/demo/demo.git[foo,bar]" )
237
+
238
+ expected = """\
239
+
240
+ Updating dependencies
241
+ Resolving dependencies...
242
+
243
+ Writing lock file
244
+
245
+
246
+ Package operations: 4 installs, 0 updates, 0 removals
247
+
248
+ - Installing cleo (0.6.5)
249
+ - Installing pendulum (1.4.4)
250
+ - Installing tomlkit (0.5.5)
251
+ - Installing demo (0.1.2 9cf87a2)
252
+ """
253
+
254
+ assert expected == tester .io .fetch_output ()
255
+
256
+ assert len (installer .installs ) == 4
257
+
258
+ content = app .poetry .file .read ()["tool" ]["poetry" ]
259
+
260
+ assert "demo" in content ["dependencies" ]
261
+ assert content ["dependencies" ]["demo" ] == {
262
+ "git" : "https://github.com/demo/demo.git" ,
263
+ "extras" : ["foo" , "bar" ],
264
+ }
265
+
266
+
167
267
def test_add_directory_constraint (app , repo , installer , mocker ):
168
268
p = mocker .patch ("poetry.utils._compat.Path.cwd" )
169
269
p .return_value = Path (__file__ ) / ".."
@@ -304,7 +404,7 @@ def test_add_file_constraint_sdist(app, repo, installer, mocker):
304
404
}
305
405
306
406
307
- def test_add_constraint_with_extras (app , repo , installer ):
407
+ def test_add_constraint_with_extras_option (app , repo , installer ):
308
408
command = app .find ("add" )
309
409
tester = CommandTester (command )
310
410
0 commit comments