Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 642eb1a

Browse files
committed
tests: fixes for Windows in "option" modules
1 parent 04af42c commit 642eb1a

File tree

1 file changed

+41
-24
lines changed

1 file changed

+41
-24
lines changed

tests/option_test.py renamed to tests/option.py

+41-24
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ def test_without_backup_path_3(self):
4242
self.assertEqual(1, 0, "Expecting Error because '-B' parameter is not specified.\n Output: {0} \n CMD: {1}".format(
4343
repr(self.output), self.cmd))
4444
except ProbackupException as e:
45-
self.assertEqual(e.message, 'ERROR: required parameter not specified: BACKUP_PATH (-B, --backup-path)\n',
45+
self.assertIn(
46+
'ERROR: required parameter not specified: BACKUP_PATH (-B, --backup-path)',
47+
e.message,
4648
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(repr(e.message), self.cmd))
4749

4850

@@ -63,8 +65,9 @@ def test_options_4(self):
6365
self.assertEqual(1, 0, "Expecting Error because 'instance' parameter is not specified.\n Output: {0} \n CMD: {1}".format(
6466
repr(self.output), self.cmd))
6567
except ProbackupException as e:
66-
self.assertEqual(e.message,
67-
'ERROR: required parameter not specified: --instance\n',
68+
self.assertIn(
69+
'ERROR: required parameter not specified: --instance',
70+
e.message,
6871
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(repr(e.message), self.cmd))
6972

7073
# backup command failure without backup mode option
@@ -73,7 +76,8 @@ def test_options_4(self):
7376
self.assertEqual(1, 0, "Expecting Error because '-b' parameter is not specified.\n Output: {0} \n CMD: {1}".format(
7477
repr(self.output), self.cmd))
7578
except ProbackupException as e:
76-
self.assertIn('ERROR: required parameter not specified: BACKUP_MODE (-b, --backup-mode)',
79+
self.assertIn(
80+
'ERROR: required parameter not specified: BACKUP_MODE (-b, --backup-mode)',
7781
e.message,
7882
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(repr(e.message), self.cmd))
7983

@@ -83,8 +87,9 @@ def test_options_4(self):
8387
self.assertEqual(1, 0, "Expecting Error because backup-mode parameter is invalid.\n Output: {0} \n CMD: {1}".format(
8488
repr(self.output), self.cmd))
8589
except ProbackupException as e:
86-
self.assertEqual(e.message,
87-
'ERROR: invalid backup-mode "bad"\n',
90+
self.assertIn(
91+
'ERROR: invalid backup-mode "bad"',
92+
e.message,
8893
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(repr(e.message), self.cmd))
8994

9095
# delete failure without delete options
@@ -94,8 +99,9 @@ def test_options_4(self):
9499
self.assertEqual(1, 0, "Expecting Error because delete options are omitted.\n Output: {0} \n CMD: {1}".format(
95100
repr(self.output), self.cmd))
96101
except ProbackupException as e:
97-
self.assertEqual(e.message,
98-
'ERROR: You must specify at least one of the delete options: --expired |--wal |--merge-expired |--delete-invalid |--backup_id\n',
102+
self.assertIn(
103+
'ERROR: You must specify at least one of the delete options: --expired |--wal |--merge-expired |--delete-invalid |--backup_id',
104+
e.message,
99105
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(repr(e.message), self.cmd))
100106

101107

@@ -106,7 +112,9 @@ def test_options_4(self):
106112
self.assertEqual(1, 0, "Expecting Error because backup ID is omitted.\n Output: {0} \n CMD: {1}".format(
107113
repr(self.output), self.cmd))
108114
except ProbackupException as e:
109-
self.assertTrue("option requires an argument -- 'i'" in e.message,
115+
self.assertIn(
116+
"option requires an argument -- 'i'",
117+
e.message,
110118
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(repr(e.message), self.cmd))
111119

112120
# Clean after yourself
@@ -118,12 +126,16 @@ def test_options_5(self):
118126
fname = self.id().split(".")[3]
119127
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
120128
node = self.make_simple_node(
121-
base_dir=os.path.join(module_name, fname, 'node'),
122-
pg_options={
123-
'max_wal_senders': '2'})
129+
base_dir=os.path.join(module_name, fname, 'node'))
124130

125-
self.assertEqual("INFO: Backup catalog '{0}' successfully inited\n".format(backup_dir),
126-
self.init_pb(backup_dir))
131+
output = self.init_pb(backup_dir)
132+
self.assertIn(
133+
"INFO: Backup catalog",
134+
output)
135+
136+
self.assertIn(
137+
"successfully inited",
138+
output)
127139
self.add_instance(backup_dir, 'node', node)
128140

129141
node.slow_start()
@@ -138,8 +150,9 @@ def test_options_5(self):
138150
self.assertEqual(1, 0, "Expecting Error because of garbage in pg_probackup.conf.\n Output: {0} \n CMD: {1}".format(
139151
repr(self.output), self.cmd))
140152
except ProbackupException as e:
141-
self.assertEqual(e.message,
142-
'ERROR: Syntax error in " = INFINITE"\n',
153+
self.assertIn(
154+
'ERROR: Syntax error in " = INFINITE',
155+
e.message,
143156
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(repr(e.message), self.cmd))
144157

145158
self.clean_pb(backup_dir)
@@ -156,8 +169,9 @@ def test_options_5(self):
156169
self.assertEqual(1, 0, "Expecting Error because of invalid backup-mode in pg_probackup.conf.\n Output: {0} \n CMD: {1}".format(
157170
repr(self.output), self.cmd))
158171
except ProbackupException as e:
159-
self.assertEqual(e.message,
160-
'ERROR: Invalid option "BACKUP_MODE" in file "{0}"\n'.format(conf_file),
172+
self.assertIn(
173+
'ERROR: Invalid option "BACKUP_MODE" in file',
174+
e.message,
161175
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(repr(e.message), self.cmd))
162176

163177
self.clean_pb(backup_dir)
@@ -177,8 +191,9 @@ def test_options_5(self):
177191
self.assertEqual(1, 0, "Expecting Error because option system-identifier cannot be specified in command line.\n Output: {0} \n CMD: {1}".format(
178192
repr(self.output), self.cmd))
179193
except ProbackupException as e:
180-
self.assertEqual(e.message,
181-
'ERROR: Option system-identifier cannot be specified in command line\n',
194+
self.assertIn(
195+
'ERROR: Option system-identifier cannot be specified in command line',
196+
e.message,
182197
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(repr(e.message), self.cmd))
183198

184199
# invalid value in pg_probackup.conf
@@ -191,8 +206,9 @@ def test_options_5(self):
191206
self.assertEqual(1, 0, "Expecting Error because option -C should be boolean.\n Output: {0} \n CMD: {1}".format(
192207
repr(self.output), self.cmd))
193208
except ProbackupException as e:
194-
self.assertEqual(e.message,
195-
'ERROR: Invalid option "SMOOTH_CHECKPOINT" in file "{0}"\n'.format(conf_file),
209+
self.assertIn(
210+
'ERROR: Invalid option "SMOOTH_CHECKPOINT" in file',
211+
e.message,
196212
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(repr(e.message), self.cmd))
197213

198214
self.clean_pb(backup_dir)
@@ -209,8 +225,9 @@ def test_options_5(self):
209225
self.assertEqual(1, 0, 'Expecting Error because of invalid option "TIMELINEID".\n Output: {0} \n CMD: {1}'.format(
210226
repr(self.output), self.cmd))
211227
except ProbackupException as e:
212-
self.assertEqual(e.message,
213-
'ERROR: Invalid option "TIMELINEID" in file "{0}"\n'.format(conf_file),
228+
self.assertIn(
229+
'ERROR: Invalid option "TIMELINEID" in file',
230+
e.message,
214231
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(repr(e.message), self.cmd))
215232

216233
# Clean after yourself

0 commit comments

Comments
 (0)