Skip to content

Commit 29e89e2

Browse files
committed
Removing add_category function
1 parent adff033 commit 29e89e2

File tree

2 files changed

+0
-76
lines changed

2 files changed

+0
-76
lines changed

qiita_db/metadata_template/sample_template.py

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -433,37 +433,3 @@ def update_category(self, category, samples_and_values):
433433
for k, v in viewitems(samples_and_values):
434434
sample = self[k]
435435
sample[category] = v
436-
437-
def add_category(self, category, samples_and_values, dtype, default):
438-
"""Add a metadata category
439-
440-
Parameters
441-
----------
442-
category : str
443-
The category to add
444-
samples_and_values : dict
445-
A mapping of {sample_id: value}
446-
dtype : str
447-
The datatype of the column
448-
default : object
449-
The default value associated with the column. This must be
450-
specified as these columns are added "not null".
451-
452-
Raises
453-
------
454-
QiitaDBDuplicateError
455-
If the column already exists
456-
"""
457-
table_name = self._table_name(self.study_id)
458-
conn_handler = SQLConnectionHandler()
459-
460-
if category in self.categories():
461-
raise QiitaDBDuplicateError(category, "N/A")
462-
463-
conn_handler.execute("""
464-
ALTER TABLE qiita.{0}
465-
ADD COLUMN {1} {2}
466-
NOT NULL DEFAULT '{3}'""".format(table_name, category, dtype,
467-
default))
468-
469-
self.update_category(category, samples_and_values)

qiita_db/metadata_template/test/test_sample_template.py

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,48 +1196,6 @@ def test_update(self):
11961196
with self.assertRaises(QiitaDBError):
11971197
st.update(self.metadata_dict_updated_column_error)
11981198

1199-
def test_add_category(self):
1200-
column = "new_column"
1201-
dtype = "varchar"
1202-
default = "stuff"
1203-
mapping = {'1.SKB1.640202': "1",
1204-
'1.SKB5.640181': "2",
1205-
'1.SKD6.640190': "3"}
1206-
1207-
exp = {
1208-
'1.SKB1.640202': "1",
1209-
'1.SKB2.640194': "stuff",
1210-
'1.SKB3.640195': "stuff",
1211-
'1.SKB4.640189': "stuff",
1212-
'1.SKB5.640181': "2",
1213-
'1.SKB6.640176': "stuff",
1214-
'1.SKB7.640196': "stuff",
1215-
'1.SKB8.640193': "stuff",
1216-
'1.SKB9.640200': "stuff",
1217-
'1.SKD1.640179': "stuff",
1218-
'1.SKD2.640178': "stuff",
1219-
'1.SKD3.640198': "stuff",
1220-
'1.SKD4.640185': "stuff",
1221-
'1.SKD5.640186': "stuff",
1222-
'1.SKD6.640190': "3",
1223-
'1.SKD7.640191': "stuff",
1224-
'1.SKD8.640184': "stuff",
1225-
'1.SKD9.640182': "stuff",
1226-
'1.SKM1.640183': "stuff",
1227-
'1.SKM2.640199': "stuff",
1228-
'1.SKM3.640197': "stuff",
1229-
'1.SKM4.640180': "stuff",
1230-
'1.SKM5.640177': "stuff",
1231-
'1.SKM6.640187': "stuff",
1232-
'1.SKM7.640188': "stuff",
1233-
'1.SKM8.640201': "stuff",
1234-
'1.SKM9.640192': "stuff"}
1235-
1236-
self.tester.add_category(column, mapping, dtype, default)
1237-
1238-
obs = {k: v['new_column'] for k, v in self.tester.items()}
1239-
self.assertEqual(obs, exp)
1240-
12411199
def test_to_file(self):
12421200
"""to file writes a tab delimited file with all the metadata"""
12431201
fd, fp = mkstemp()

0 commit comments

Comments
 (0)