# Copyright 2016 Mario Graff (https://github.com/mgraffg)

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

#     http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


def test_tweet_iterator():
    import os
    from b4msa.textmodel import tweet_iterator
    dirname = os.path.dirname(__file__)
    [x for x in tweet_iterator(dirname + '/text.json')]

@@ -637,16 +637,32 @@
 port os%0A
+    import gzip%0A
     from
@@ -704,19 +704,17 @@
 tor%0A    
-dir
+f
 name = o
@@ -737,20 +737,39 @@
 _file__)
-%0A   
+ + '/text.json'%0A    a =
  %5Bx for 
@@ -792,29 +792,340 @@
 tor(
-dirname + '/text.json')%5D
+fname)%5D%0A    fname_gz = fname + '.gz'%0A    with open(fname, 'r') as fpt:%0A        with gzip.open(fname_gz, 'w') as fpt2:%0A            fpt2.write(fpt.read().encode('ascii'))%0A    b = %5Bx for x in tweet_iterator(fname_gz)%5D%0A    assert len(a) == len(b)%0A    for a0, b0 in zip(a, b):%0A        assert a0%5B'text'%5D == b0%5B'text'%5D%0A    os.unlink(fname_gz)
 %0A

test tweet_iterator