Skip to content

Commit

Permalink
Added bad ingest test
Browse files Browse the repository at this point in the history
  • Loading branch information
BrandonHaynes committed Mar 2, 2017
1 parent d5db777 commit bcefd43
Showing 1 changed file with 32 additions and 26 deletions.
58 changes: 32 additions & 26 deletions integration_tests.py
Expand Up @@ -2,7 +2,6 @@

import unittest
from collections import Counter
from tempfile import NamedTemporaryFile
from myria import MyriaConnection, MyriaRelation, MyriaQuery, MyriaError


Expand Down Expand Up @@ -35,9 +34,8 @@ def test(self):
class IngestEmptyQueryTest(MyriaTestBase):
def test(self):
# Create empty file
with NamedTemporaryFile() as f:
#TODO change URL to local file
program = """
#TODO change URL to local file
program = """
emptyrelation = load('https://s3-us-west-2.amazonaws.com/bhaynestemp/emptyrelation', csv(schema(foo:string, bar:int)));
store(emptyrelation, emptyrelation);
"""
Expand All @@ -49,38 +47,46 @@ def test(self):

class UploadAndReplaceDataTest(MyriaTestBase):
def test(self):
with NamedTemporaryFile() as f:
data = "foo,3242\n" \
"bar,321\n"\
"baz,104"
f.write(data)
#TODO change URL to local file
program = """
data = "foo,3242\n" \
"bar,321\n"\
"baz,104"
#TODO change URL to local file
program = """
uploaddatatest = load('https://s3-us-west-2.amazonaws.com/bhaynestemp/uploaddatatest', csv(schema(s:string, i:int)));
store(uploaddatatest, uploaddatatest);
"""
expected = [{u's': u'foo', u'i': 3242},
{u's': u'bar', u'i': 321},
{u's': u'baz', u'i': 104}]
query = MyriaQuery.submit(program)
self.assertEqual(query.status, 'SUCCESS')
self.assertListOfDictsEqual(query.to_dict(), expected)
expected = [{u's': u'foo', u'i': 3242},
{u's': u'bar', u'i': 321},
{u's': u'baz', u'i': 104}]
query = MyriaQuery.submit(program)
self.assertEqual(query.status, 'SUCCESS')
self.assertListOfDictsEqual(query.to_dict(), expected)

# Now replace with another relation
program = """
# Now replace with another relation
program = """
uploaddatatest = load('https://s3-us-west-2.amazonaws.com/bhaynestemp/uploaddatatest2',
csv(schema(s:string, i:int), delimiter='\\t'));
store(uploaddatatest, uploaddatatest);
"""
expected = [{u's': u'mexico', u'i': 42},
{u's': u'poland', u'i': 12342},
{u's': u'belize', u'i': 802304}]
query = MyriaQuery.submit(program)
self.assertEqual(query.status, 'SUCCESS')
self.assertListOfDictsEqual(query.to_dict(), expected)

expected = [{u's': u'mexico', u'i': 42},
{u's': u'poland', u'i': 12342},
{u's': u'belize', u'i': 802304}]
query = MyriaQuery.submit(program)
self.assertEqual(query.status, 'SUCCESS')
self.assertListOfDictsEqual(query.to_dict(), expected)


class BadDelimiterTest(MyriaTestBase):
def test(self):
# Create empty file
#TODO change URL to local file
program = """
r = load('https://s3-us-west-2.amazonaws.com/bhaynestemp/simple_two_col_int.txt',
csv(schema(x:int, y:int), delimiter=' '));
store(r, r);
"""
query = MyriaQuery.submit(program)
self.assertEqual(query.status, 'ERROR')

if __name__ == '__main__':
unittest.main()

0 comments on commit bcefd43

Please sign in to comment.