def test_insert(self) -> None: table = CassandraTable(self.mock_config, self.keyspace) table.insert({ 'col1': 'mock_id', 'col2': 1546304400000, 'col3': 26.919388, 'col4': -8.932613 }, keyspace='mock_keyspace') self.assertEqual(1, len(table.statements)) self.assertEqual( "INSERT INTO mock_keyspace.mock_table " "JSON '{\"col1\": \"mock_id\", \"col2\": 1546304400000, " "\"col3\": 26.919388, \"col4\": -8.932613, \"day\": 1546300800000, " "\"h3\": \"835525fffffffff\"}' ;", table.statements[0] ) for _ in range(4): table = table.insert({ 'col1': 'mock_id', 'col2': 1546304400000, 'col3': 26.919388, 'col4': -8.932613 }, keyspace='mock_keyspace') self.assertEqual(5, len(table.statements)) for i in range(5): self.assertEqual( "INSERT INTO mock_keyspace.mock_table " "JSON '{\"col1\": \"mock_id\", \"col2\": 1546304400000, " "\"col3\": 26.919388, \"col4\": -8.932613, " "\"day\": 1546300800000, \"h3\": \"835525fffffffff\"}' ;", table.statements[i] )
def test_insert_with_split(self) -> None: self.mock_config['split'] = 'day' table = CassandraTable(self.mock_config, self.keyspace) table.insert({ 'col1': 'mock_id', 'col2': 1546304400000, 'col3': 26.919388, 'col4': -8.932613 }, keyspace='mock_keyspace') self.assertEqual(1, len(table.statements)) self.assertEqual( "INSERT INTO mock_keyspace.mock_table_01_01_2019 " "JSON '{\"col1\": \"mock_id\", \"col2\": 1546304400000, " "\"col3\": 26.919388, \"col4\": -8.932613, " "\"day\": 1546300800000, \"h3\": \"835525fffffffff\"}' ;", table.statements[0] )